#include <algorithm>
#include <vector>

using namespace std;


struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    vector<int> reversePrint(ListNode* head) {
        vector<int> ans;
        while (head != nullptr) {
            ans.emplace_back(head->val);
            head = head->next;
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};

int main() {
    ListNode l1(1), l2(3), l3(2);
    l1.next = &l2;
    l2.next = &l3;
    Solution solution;
    solution.reversePrint(&l1);
}
